import logging

from django.conf import settings
from django.core.mail import send_mail

logger = logging.getLogger('django')


def send_verification_email(to_email, verify_url):
    """发送邮件"""
    subject = '小鱼商城邮箱验证'
    html_message = '<p>尊敬的用户您好！</p>' \
                   '<p>感谢您使用小鱼商城。</p>' \
                   '<p>您的邮箱为：%s 。请单击此链接验证您的邮箱：</p>' \
                   '<p><a href="%s">%s<a></p>' % (to_email, verify_url, verify_url)

    try:
        send_mail(subject, '', settings.EMAIL_FROM, [to_email], html_message=html_message)
    except Exception as e:
        logger.error(e)